﻿<?php
 function getMailObj()
 {
 		include "lib/mail/class.phpmailer.php";
        $mail = new PHPMailer();   
        $mail->IsSMTP();                  // send via SMTP   
        $mail->Host = "smtp.sina.net";   // SMTP servers   
        $mail->SMTPAuth = true;           // turn on SMTP authentication   
        $mail->Username = "shsjxt@a4a.com.cn";     // SMTP username  注意：普通邮件认证不需要加 @域名   
        $mail->Password = ""; // SMTP password   
        $mail->From = "shsjxt@a4a.com.cn";      // 发件人邮箱   
        $mail->FromName =  "内容厨房系统";  // 发件人   

        $mail->CharSet = "UTF-8";   // 这里指定字符集！   
        $mail->Encoding = "base64";
        $mail->IsHTML(true);  // send as HTML      
        $mail->AltBody ="text/html";   
        $mail->Subject = "内容厨房";   
        $mail->IsHTML(true);  // send as HTML   
        $mail->AltBody ="text/html";
        return $mail;
 }
 function smtp_mail($sendto_email,$subject,$body,$user_name){   
 	    $mail = getMailObj();
        $mail->AddAddress($sendto_email,$user_name);  // 收件人邮箱和姓名   
        //$mail->AddReplyTo("yourmail@yourdomain.com","yourdomain.com");   
        //$mail->WordWrap = 50; // set word wrap 换行字数   
        //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment 附件   
        //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");   
        // 邮件主题   
        $mail->Subject = $subject;   
        // 邮件内容   
        $mail->Body = $body;                                               
        
        if(!$mail->Send())   
        {   
            //echo "邮件发送有误 <p>";   
            //echo "邮件错误信息: " . $mail->ErrorInfo;   
            return false;
            //exit;   
        }   
        else {   
            //echo "$user_name 邮件发送成功!<br />";   
            return true;
        }   
  } 

?>